This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
photo.data <- officials %>%
mutate(ifelse(is.na(photoUrl) == FALSE, paste0(""), "Not available"))
officials$photoUrl <- photo.data[, 7]
num.to.rep <- unlist(lapply(parsed.data$offices$officialIndices, length))
expanded <- offices[rep(row.names(offices), num.to.rep), ]
officials <- officials %>% mutate(index = row_number() -1)
expanded <- expanded %>% mutate(index = row_number() -1) %>%
rename(position = name)
joined <- left_join(officials, expanded)
## Joining, by = "index"
joined <- select(joined, name, position, party, emails, phones, photoUrl)
gender.plot <- barplot(gender.data, horiz = TRUE)
party.plot <- barplot(party.data, horiz = TRUE)
kable(joined)
| name | position | party | emails | phones | photoUrl |
|---|---|---|---|---|---|
| Donald J. Trump | President of the United States | Republican | NULL | (202) 456-1111 | |
| Mike Pence | Vice-President of the United States | Republican | NULL | (202) 456-1111 | |
| Dianne Feinstein | United States Senate | Democratic | NULL | (202) 224-3841 | |
| Kamala D. Harris | United States Senate | Democratic | NULL | (202) 224-3553 | |
| Edmund G. Brown Jr. | Governor | Democratic | NULL | (916) 445-2841 | Not available |
| Gavin Newsom | Lieutenant Governor | Democratic | gavin@gavinnewsom.com | (916) 445-8994 |